import http from '../util/request.js'

export default {
    add:(obj)=>{
        return http({
            url:'/api/user',
            method:'post',
            data:obj,
            headers: {
                //定义将数据以json的形式传入后台(java)
                'Content-Type': 'application/json'
            }
        });
    },
     edit:(obj)=>{
        return http({
            url:'/api/user',
            method:'put',
            data:obj,
            headers: {
                //定义将数据以json的形式传入后台(java)
                'Content-Type': 'application/json'
            }
        });
     },
     del:(id)=>{
        return http({
            url:'/api/user/'+id,
            method:'delete',
        });
     },
    page:(obj)=>{
        return http({
            url:'/api/user/page',
            method:'get',
            params:obj
        });
    },
    resetPassword:(email,code,newPassword)=>{
        return http({
            url:'/api/user/reset-password',
            method:'post',
            params:{
                email: email,
                code: code,
                newPassword: newPassword
            }
        });
    },
    updatePassword:(oldPassword,newPassword)=>{
        return http({
            url:'/api/user/update-password',
            method:'post',
            params:{
                oldPassword: oldPassword,
                newPassword: newPassword
            }
        });
    }

}